my_dict = {
    'name': 'Jagochan',
    'gender': '女'
}

# 【1】新增和修改元素
print(my_dict, len(my_dict))
# 新增元素
my_dict['age'] = 6
print(my_dict, len(my_dict))
# 修改元素
print(my_dict['age'] == 6)
my_dict['age'] = 8
my_dict['gender'] = '男'
print(my_dict['age'] == 8)
print(my_dict, len(my_dict))
print('🍀🍀🍀🍀🍀🍀')

# 【2】删除键值对
exam_info = {
    '王力宏': {
        '语文': 77,
        '数学': 66,
        '英语': 99
    },
    '周杰伦': {
        '语文': 88,
        '数学': 86,
        '英语': 66
    },
    '林俊杰': {
        '语文': 99,
        '数学': 98,
        '英语': 66
    }
}
print(F'删除前：{exam_info}')
wlh_info = exam_info.pop('王力宏')
print(F'王力宏的成绩信息：{wlh_info}')
print(F'删除后：{exam_info}')
print('🍀🍀🍀🍀🍀🍀')

# 【3】清空字典
print(F'清空前：{my_dict}')
my_dict.clear()
print(F'清空后：{my_dict}')
print('🍀🍀🍀🍀🍀🍀')

# 【4】获取字典中全部的KEY
my_dict = {
    'name': 'Jagochan',
    'age': 8,
    'score': 99.5,
    'is_boy': True,
    'is_graduated': False
}
keys = my_dict.keys()
# dict_keys(['name', 'age', 'score', 'is_boy', 'is_graduated']) <class 'dict_keys'>
print(keys, type(keys))
print('🍀🍀🍀🍀🍀🍀')

# 【5】遍历字典(1)
keys = my_dict.keys()
for key in keys:
    print(F'{key}👉{my_dict[key]}')

# 【6】遍历字典(2)
for key in my_dict:
    print(F'{key} → {my_dict[key]}')
